<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <title>MiniCheckout</title>
    <style type="text/css">
     span {
     	margin: 10px;
     	border:1px solid red;
     }
    </style>
</head>
<body>
<header>
    <div class="h_content">
        <span></span>
    </div>
</header> 
<section class="block">

    <div>
        <p>token</p>
        <input id="token" />
    </div>
    <div>
        <p>payConfigId</p>
        <input id="payConfigId" />
    </div>
    <div>
        <p>httpurl</p>
        <input id="httpurl" value="https://www.likewawa.com/miaozhuapc/v1/ping/createCharge?payConfigId=1&channel="/>
    </div>
    <div class="content2">
        <div class="app">
            <div class="ch">
                <div class="ch">
            <span class="up" onclick="wap_pay('upacp_wap')">银联 WAP</span> 
              <span class="up" onclick="wap_pay('alipay_wap')">支付宝 WAP</span> 
              <span class="up" onclick="wap_pay('bfb_wap')">百度钱包 WAP</span> 
             <span class="up" onclick="wap_pay('jdpay_wap')">京东支付 WAP</span> 
               <span class="up" onclick="wap_pay('yeepay_wap')">易宝支付 WAP</span> 
             <span class="up" onclick="wap_pay('wx_pub')">微信浏览器内公众号支付 WAP wx_pub</span> 
             <span class="up" onclick="wap_pay('wx_wap')">微信浏览器内公众号支付 WAP  wx_wap</span>
         </div> 
            </div>
        </div>
    </div>
</section>
<script src="pingpp.js" type="text/javascript"></script>
<script src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js "type="text/javascript"></script>
<script>
function wap_pay(channel) {

    var token = document.getElementById("token").value;
    var httpurl = document.getElementById("httpurl").value;

    var YOUR_URL = httpurl+channel;
    var xhr = new XMLHttpRequest();
    xhr.open("GET", YOUR_URL, true);
    //xhr.setRequestHeader("Content-type", "application/json");
    xhr.setRequestHeader('WAWA_TOKEN', token);
    xhr.send(JSON.stringify({
        "payConfigId":1,
        "channel": channel
    }));

    xhr.onreadystatechange = function () {
        if (xhr.readyState == 4 && xhr.status == 200) {
            console.log(xhr.responseText);
            alert(JSON.parse(xhr.responseText).pingCharge)
            pingpp.createPayment(JSON.parse(xhr.responseText).body, function(result, err) {
                console.log(result);
                console.log(err.msg);
                console.log(err.extra);
            });
        }
    }
    
/*     $.ajax({
        type: "POST",
        url: YOUR_URL,
        data: {"payConfigId":1},
       // headers:{'WAWA_TOKEN': '308d302df6774dc1941a3e2f6a18df16'},
        //headers : {'CASTING_TOKEN':123},
        // cache: false,
       // async : false,
        dataType: "json",
        beforeSend: function(request) {
            //request.setRequestHeader("WAWA_TOKEN", "308d302df6774dc1941a3e2f6a18df16");
        },
        success: function (data ,textStatus, jqXHR)
        {
        	console.log(data);
            pingpp.createPayment(xhr.responseText, function(result, err) {
                console.log(result);
                console.log(err.msg);
                console.log(err.extra);
            });
        },
        error:function (XMLHttpRequest, textStatus, errorThrown) {      
            alert("请求失败！");
        }
     }); */
}
</script>
</body>
</html>
